#ifndef IVISUALISATION_H
#define IVISUALISATION_H

#include "Vector2i.h"
#include <string>
using namespace std;

class CTexture;
class CAnimation;

//!Interface class for the Visualisation component.
class IVisualisation
{
public:
	//!Destructor
	virtual ~IVisualisation(){};

	//!Initialisation function
	virtual bool init(void)=0;

	///!Load a texture from a file.
	/*!
	\param indexGfx Pointer to an int. The function fill it with the index of the textures.
	\param adrTexture Adresse of the texture to load.
	\param spriteWidth Width of the sprite that the texture contained. If there is no sprite, put 0.
	\param spriteHeight Height of the sprite that the texture contained. If there is no sprite, put 0.
	\param nbOfSprite The number of sprite contained by the texture. If there is no sprite, put 0.
	\param nbOfSpritePerRow The number of sprite per row in the texture. If there is no sprite, put 0.
	\return True if the texture is loaded. Flase if it failed.
	*/
	virtual bool loadTexture(int* indexGfx, const string &adrTexture, int spriteWidth, int spriteHeight, int nbOfSprite, 
		int nbOfSpritePerRow)=0;

	//!Load a texture fron a zpak file loaded in memory.
	/*!
	\param indexGfx Pointer to an int. The function fill it with the index of the textures.
	\param filename Name of the file to load and packed in the zpak file.
	\param spriteWidth Width of the sprite that the texture contained. If there is no sprite, put 0.
	\param spriteHeight Height of the sprite that the texture contained. If there is no sprite, put 0.
	\param nbOfSprite The number of sprite contained by the texture. If there is no sprite, put 0.
	\param nbOfSpritePerRow The number of sprite per row in the texture. If there is no sprite, put 0.
	\return True if the texture is loaded. Flase if it failed.
	*/
	virtual bool loadTextureFromMemory(int* indexGfx, const string& filename, int spriteWidth, int spriteHeight, 
		int nbOfSprite, int nbOfSpritePerRow)=0;

	//!Create an animation.
	/*!
	\param indexAnimation Pointer to an int representing the animation.
	\param indexGfx Index of the texture that contains the sprite ofr the animation.
	\param indexFirstSprite Index of the first sprite of the animation in the texture.
	\param indexLastSprite Index of the last sprite of the animation in the texture.
	\param offsetTime Time that every frame of the animation is displayed.
	\return True if the animation is created. False if it failed.
	*/
	virtual bool loadAnimation(int* indexAnimation, int indexGfx, int indexFirstSprite, int indexLastSprite, 
		int offsetTime)=0;

	//!Load a font from a file. A font is a simple texture where every sprite is a character.
	/*!
	\param indexFont Pointer to an int. The function fills it with the index of the font.
	\param adrTexture Adress of the font to load.
	\param spriteWidth Width of every character of the font.
	\param spriteHeight Height of every character of the font.
	\param nbOfSprite Number of character in the texture.
	\param nbOfSpritePerRow Number of character per row in the texture.
	\return True if the font is loaded. False if it failed.
	*/
	virtual bool loadFont(int* indexFont, const string& adrTexture, int spriteWidth, int spriteHeight, int nbOfSprite,
		int nbOfSpritePerRow)=0;

	//!Load a font from a zpak file loaded in memory.
	/*!
	\param indexFont Pointer to an int. The function fills it with the index of the font.
	\param filename Name of the file to load and packed in a zpak file already loaded.
	\param spriteWidth Width of every character of the font.
	\param spriteHeight Height of every character of the font.
	\param nbOfSprite Number of character in the texture.
	\param nbOfSpritePerRow Number of character per row in the texture.
	\return True if the font is loaded. False if it failed.
	*/
	virtual bool loadFontFromMemory(int* indexFont, const string& filename, int spriteWidth, int spriteHeight, 
		int nbOfSprite, int nbOfSpritePerRow)=0;

	//! Prepare the screen to render.
	virtual void preRender(void)=0;

	//!Post render function.
	virtual void postRender(void)=0;

	//!Display a texture
	/*!
	\param index Index of the texture to display.
	\param position Position of the texture.
	*/
	virtual void displayTexture(int index, const CVector2i& position)=0;

	//!Display a sprite.
	/*!
	\param indexGfx Index a the texture that contains the sprite.
	\param indexSprite Index of the sprite.
	\param position Position of the sprite.
	*/
	virtual void displaySprite(int indexGfx, int indexSprite, const CVector2i& position)=0;

	//!Display an animation.
	/*!
	\param indexAnimation index of the animation to display.
	\param position Position of the animation.
	\param indexCurrentSprite Pointer to an int. The function fills it with the index of the current sprite of
	the animation.
	\param timeLastSprite Pointer to an int. The function fills it with the start time of displayed of the last sprite.
	\return True ifthe animation is over. False if it's not iver.
	*/
	virtual bool displayAnimation(int indexAnimation, const CVector2i& position, 
		int* indexCurrentSprite, int* timeLastSprite)=0;

	//!Display a character
	/*!
	\param indexFont Index of the font.
	\param position Position where the character has to be displayed.
	\param character The character to display.
	\return Always return true.
	*/
	virtual bool displayCharacter(int indexFont, const CVector2i& position, char character)=0;

	//!Display text.
	/*!
	\param indexFont Index of the font tu use.
	\param position Position where the text has to be displayed
	\param text The text to display.
	\return Always return true;
	*/
	virtual bool displayText(int indexFont, const CVector2i& position, const string& text)=0;

	//!Display a digit
	/*!
	\param indexFont Index of the font tu use.
	\param position Position where the text has to be displayed
	\param digit The digit to display.
	\return Always return true;
	*/
	virtual bool displayDigit(int indexFont, const CVector2i& position, int digit)=0;

	//!Display a number
	/*!
	\param indexFont Index of the font tu use.
	\param position Position where the text has to be displayed
	\param number The number to display.
	\return Always return true;
	*/
	virtual bool displayNumber(int indexFont, const CVector2i& position, int number)=0;

	//!Get the width of a texture
	/*!
	\param indexGfx The index of the texture
	\return The width of the texture.
	*/
	virtual int getTextureWidth(int indexGfx)const=0;

	//!Get the height of a texture
	/*!
	\param indexGfx The index of the texture
	\return The height of the texture.
	*/
	virtual int getTextureHeight(int indexGfx)const=0;

	//!Get the width of a sprite
	/*!
	\param indexGfx The index of the texture
	\return The width of a sprite.
	*/
	virtual int getSpriteWidth(int indexGfx)const=0;

	//!Get the height of a sprite
	/*!
	\param indexGfx The index of the texture
	\return The height of the sprite.
	*/
	virtual int getSpriteHeight(int indexGfx)const=0;

	//!Get the width of an animation
	/*!
	\param indexAnim The index of the animation
	\return The width of the animation.
	*/
	virtual int getAnimationSpriteWidth(int indexAnim)const=0;

	//!Get the height of an animation
	/*!
	\param indexAnim The index of the animation
	\return The height of the animation.
	*/
	virtual int getAnimationSpriteHeight(int indexAnim)const=0;
};

#endif
